home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / Tools / EasyGUI / Plugins / toolify.e < prev   
Encoding:
Text File  |  1997-01-30  |  2.2 KB  |  76 lines

  1. OPT MODULE, PREPROCESS
  2.  
  3. MODULE 'intuition/intuition', 'intuition/gadgetclass',
  4.        'libraries/gadtools',
  5.        'tools/textlen',
  6.        'tools/EasyGUI',
  7.        'workbench/startup', 'workbench/workbench',
  8.        'gadtools', 'wb'
  9.  
  10. RAISE "tlfy" IF AddAppMenuItemA()=NIL,
  11.       "tlfy" IF CreateMsgPort()=NIL
  12.  
  13. -> Share gadtoolsbase and workbenchbase with EasyGUI
  14.  
  15. EXPORT OBJECT toolify OF plugin
  16.   disabled
  17. PRIVATE
  18.   toolify:PTR TO gadget
  19.   label, toollabel
  20.   resize
  21. ENDOBJECT
  22.  
  23. PROC toolify(label,toollabel=NIL,
  24.              resizex=FALSE,resizey=FALSE,disabled=FALSE) OF toolify
  25.   self.label:=IF label THEN label ELSE ''
  26.   self.toollabel:=IF toollabel THEN toollabel ELSE self.label
  27.   self.disabled:=disabled
  28.   self.resize:=(IF resizex THEN RESIZEX ELSE 0) OR
  29.                (IF resizey THEN RESIZEY ELSE 0)
  30. ENDPROC
  31.  
  32. PROC end() OF toolify IS EMPTY
  33.  
  34. PROC min_size(ta,fh) OF toolify IS textlen(self.label,ta)+16,fh+6
  35.  
  36. PROC will_resize() OF toolify IS self.resize
  37.  
  38. -> Don't need to define this:
  39. ->PROC render(ta,x,y,xs,ys,w) OF toolify IS EMPTY
  40.  
  41. PROC gtrender(gl,vis,ta,x,y,xs,ys,w) OF toolify
  42.   -> Or, a gadget in the title bar would have also been nice...
  43.   self.toolify:=CreateGadgetA(BUTTON_KIND,gl,
  44.                  [x,y,xs,ys,self.label,ta,0,
  45.                   PLACETEXT_IN,vis,NIL]:newgadget, [NIL])
  46.   IF self.toolify=NIL THEN Raise("tlfy")
  47. ENDPROC self.toolify
  48.  
  49. -> Don't need to define this:
  50. -> PROC clear_render(win:PTR TO window) OF toolify IS EMPTY
  51.  
  52. PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF toolify
  53.   IF imsg.class=IDCMP_GADGETUP THEN RETURN imsg.iaddress=self.toolify
  54. ENDPROC FALSE
  55.  
  56. PROC message_action(class,qual,code,win:PTR TO window) OF toolify HANDLE
  57.   DEF myport=NIL, appitem=NIL, appmsg:PTR TO appmessage
  58.   closewin(self.gh)
  59.   myport:=CreateMsgPort()
  60.   appitem:=AddAppMenuItemA(0,0,self.toollabel,myport,NIL)
  61.   WaitPort(myport)
  62. EXCEPT DO
  63.   IF appitem THEN RemoveAppMenuItem(appitem)
  64.   IF myport
  65.     -> Clear away any messages that arrived at the last moment
  66.     WHILE appmsg:=GetMsg(myport) DO ReplyMsg(appmsg)
  67.     DeleteMsgPort(myport)
  68.   ENDIF
  69.   openwin(self.gh)
  70. ENDPROC FALSE
  71.  
  72. PROC setdisabled(disabled=TRUE) OF toolify
  73.   Gt_SetGadgetAttrsA(self.toolify,self.gh.wnd,NIL,[GA_DISABLED,disabled,NIL])
  74.   self.disabled:=disabled
  75. ENDPROC
  76.